<?php
$kuname = "longzs";
ini_set('display_errors', 'Off');
include("../../config.php");
require '../../myzhuaqu.php';
$result=array("code"=>1);
if($_REQUEST['kuaizhao']){
    $host=host($_REQUEST['s_url']);
    $data=getrow("select * from longzs_re where host='{$host}'");
    $data['back_time']=date("Y-m-d H:00:00");
    unset($data["id"]);
    $data['loadimg']=($data['loadimg']=="")?0:$data['loadimg'];
    $id=insertupdate("longzs_re_back",$data,"select id from longzs_re_back where host='{$host}' and back_time='{$data['back_time']}'");
    $data['id']=$id;
    $data['kuaizhaostr']=$s=getkzselectstr($host);
    echo json_encode($data);
    exit;
}

if($_REQUEST['gethistorys']){
    $host=host($_REQUEST['s_url']);
    $s=getkzselectstr($host);
    echo json_encode(array("str"=>$s));
    exit;
}

if($_REQUEST['gethistory']){
    $id=$_REQUEST['id'];
    $fieldname=$_REQUEST['fieldname'];
    $text=gethistory($id,$fieldname);
    echo $text;
    exit;
}
if($_REQUEST['htmlnice']){
    $code=$_REQUEST['code'];
    $text=htmlnice($code);
    echo $text;
    exit;
}

function getkzselectstr($host){
    $data=query("select id,back_time from longzs_re_back where host='{$host}' order by id desc");
    $s="";
    for($i=0;$i<count($data);$i++){
        $s.="\r\n<option value={$data[$i]['id']}>{$data[$i]['back_time']}</option>";
    }
    return $s;
}

function gethistory($id,$fieldname){
    $data=getrow("select * from longzs_re_back where id='{$id}'");
    $text="<textarea style='width:100%;height:100%'>".htmlspecialchars($data[$fieldname])."</textarea>";
    return $text;
}

if($_REQUEST['getcookie']){
    $data=getone("select cookie from longzs_re where host='{$_REQUEST['host']}'");
    echo trim($data);
    exit;
}



